package com.luozongyao.eduService.controller;


import com.luozongyao.commonutils.R;
import com.luozongyao.eduService.entity.subject.OneSubject;
import com.luozongyao.eduService.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-08-10
 */
@RestController
@RequestMapping("/eduService/edu-subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    //添加课程分类
    //获取上传过来的文件,把文件内容读取出来
    @PostMapping("addSubject")
    public R addSubject(MultipartFile multipartFile){
        //得到上传过来的文件
        subjectService.saveSubject(multipartFile,subjectService);
        return R.ok();
    }
    //课程分类列表(树形)
    @GetMapping("getSubjectList")
    public R getSubjectList(){
        List<OneSubject> list =subjectService.getSubjectList();
        return R.ok().data("list",list);
    }

}

